using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using Entities;
using DAL;
namespace BUS
{
    public class tbCTDonHangBUS
    {
        public static void Insert(tbCTDonHang cTDonHang)
        {
            tbCTDonHangDAL cTDonHangDAL = new tbCTDonHangDAL();
            cTDonHangDAL.Insert(cTDonHang);
        }
        public static void Update(tbCTDonHang cTDonHang)
        {
            tbCTDonHangDAL cTDonHangDAL = new tbCTDonHangDAL();
            cTDonHangDAL.Update(cTDonHang);
        }
        public static void Delete(int iD)
        {
            tbCTDonHangDAL cTDonHangDAL = new tbCTDonHangDAL();
            cTDonHangDAL.Delete(iD);
        }
        public static tbCTDonHangCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            tbCTDonHangDAL cTDonHangDAL = new tbCTDonHangDAL();
            return cTDonHangDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbCTDonHangCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbCTDonHangDAL cTDonHangDAL = new tbCTDonHangDAL();
            return cTDonHangDAL.Get(cri.Criter, 0, 0, tbCTDonHangColumns.IdCTDonHang.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbCTDonHang GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbCTDonHangColumns.IdCTDonHang.ToString(), Condition.EQUAL, iD);
            tbCTDonHangDAL cTDonHangDAL = new tbCTDonHangDAL();
            tbCTDonHangCollection cTDonHangCollection = cTDonHangDAL.Get(cri.Criter, 0, 0, tbCTDonHangColumns.IdCTDonHang.ToString(), OrderDirection.ASC.ToString(), out total);
            if (cTDonHangCollection.Count > 0)
                return cTDonHangCollection[0];
            return null;
        }
    }
}
